class ApplicationController < ActionController::Base
  include Concerns::SEO

  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  def self.rescue_errors
    rescue_from Exception,                            with: :render_500
    rescue_from RuntimeError,                         with: :render_500
    rescue_from ActiveRecord::RecordNotFound,         with: :render_404
    rescue_from ActionController::RoutingError,       with: :render_404
    rescue_from ActionController::UnknownController,  with: :render_404
  end

  rescue_errors# unless Rails.env.development?

  def render_404
    render template: 'pages/not_found', status: 404, layout: 'blank'
  end

  def render_500
    render template: 'pages/server_error', status: 500, layout: 'blank'
  end
end
